package guiLayer;

import java.awt.*;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.*;

import java.util.ArrayList;

import modelLayer.Person;
import controlLayer.ControlPerson;

public class SplashScreen extends JWindow {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private ArrayList<Person> allPeople = new ArrayList<Person>();
	
	
	
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					SplashScreen frame = new SplashScreen();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	
	public SplashScreen()
	{
		JLabel one = new JLabel(new ImageIcon("swagometer.gif"));
		getContentPane().add(one, BorderLayout.CENTER);
		pack();
		Dimension screenSize = 
				Toolkit.getDefaultToolkit().getScreenSize();
		Dimension labelSize = one.getPreferredSize();
		setLocation(screenSize.width/2 - (labelSize.width/2),
					screenSize.height/2 - (labelSize.height/2));
		 addMouseListener(new MouseAdapter()
         {
             public void mousePressed(MouseEvent e)
             {
                 setVisible(false);
                 mainGUI.main(null);
                 dispose();
             }
         });
         
		ControlPerson ctrlPers = new ControlPerson();
		allPeople = ctrlPers.findAllPeople();
	/*	if(allPeople.size() > 40)
		{
			setVisible(false);
			dispose();
		}
		*/
		setVisible(true);
	}
	public ArrayList<Person> getAll()
	{
		return allPeople;
	}

}
